package com.ty.game.filter.log;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

import java.io.Serializable;

/**
 * @author: Troy.Chen(失足程序员, 15388152619)
 * @version: 2021-08-10 19:15
 **/
public class AgentFilter extends Filter<ILoggingEvent> implements Serializable {

    private static final long serialVersionUID = 1L;

    public static Marker AgentMarker = MarkerFactory.getMarker("agent");

    @Override
    public FilterReply decide(ILoggingEvent event) {

        if (event.getMarker() == null || !event.getMarker().getName().equalsIgnoreCase(AgentMarker.getName())) {
            return FilterReply.DENY;
        }

        return FilterReply.NEUTRAL;
    }
}
